﻿using GameKits.LitJson;
using System;

namespace ConsoleTest01
{
    class Program
    {
        static void Main(string[] args)
        {
            var sample = @"{
            ""name""  : ""Bill"",
            ""age""   : 32,
            ""awake"" : true,
            ""n""     : 1994.0226,
            ""note""  : [ ""life"", ""is"", ""but"", ""a"", ""dream"" ]
          }";

            ReadJson(sample);
        }

        public static void ReadJson(string json)
        {
            var reader = new JsonReader(json);

            Console.WriteLine("{0,14} {1,10} {2,16}", "Token", "Value", "Type");
            Console.WriteLine(new string('-', 42));

            // The Read() method returns false when there's nothing else to read
            while (reader.Read())
            {
                var type = reader.Value != null ?
                    reader.Value.GetType().ToString() : string.Empty;

                Console.WriteLine("{0,14} {1,10} {2,16}", reader.Token, reader.Value, type);
            }

            var xxx = new { Id = 1, Name = "dfddf" };

            var str = JsonMapper.ToJson(xxx);

            Console.WriteLine(str);

            var data = JsonMapper.ToObject(str);
        }
    }
}
